<template>

  <div class="background"></div>
<div v-show="isShow" align="center">

  <div style="width: 60%;background-color: white;padding: 10px" >
    <router-view></router-view>
  </div>
</div>
</template>

<script>
import {ElMessage} from 'element-plus'
import axios from "../utils/MyAxios";
import qs from "qs";

import PublicNavBar from "../components/PublicNavBar";
import Search from "./components/Search";
import Apply from "./components/Apply";
export default {
  name: "App",
  created() {
    let token = localStorage.getItem("token");
    if(token===null){
      ElMessage.warning("请先登录")
      window.open("/user/sign/login","_self")
    }else {
      let data = {
        token
      }
      axios.post("/api/user/token",qs.stringify(data))
      .then(res=>{
        console.log(res);
        data = res.data;
        if(data.code>0){
          localStorage.removeItem("token")
          localStorage.removeItem("user")
          ElMessage.warning("请先登录")
          window.open("/user/sign/login","_self")
        }else if(data.code<0){
          ElMessage.error(data.msg);
        }else {
          let authorId = Number(this.$route.query.authorId);
          if(authorId!==data.data.authorId){
            ElMessage.error("此用户无权限")
          }else {
            this.isShow = true
          }
        }
      })
    }
    
  },
  data(){
    return{
      isShow: false,
      drawer: true
    }
  },
  methods:{
    
  },
  computed:{
    
  },
  components:{
    PublicNavBar,
    Search,
    Apply
  }
}
</script>

<style scoped>
.background{
  background-image: url(../assets/bg.jpg);
  /*background-repeat:no-repeat ;*/
  background-size:100% 100%;
  width:100%;
  height:100%;  /**宽高100%是为了图片铺满屏幕 */
  z-index:-1;
  position: fixed;
  bottom: 0;
  opacity: 0.3;
}
</style>